package org.jie.guider.framework;

import org.jie.guider.framework.springboot.ShutdownHook;
import org.jie.guider.framework.springboot.ShutdownHookService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @author lijie
 */
@SpringBootApplication
public class GuiderSpringBootApplication {
    private static final Logger LOG = LoggerFactory.getLogger(GuiderSpringBootApplication.class);

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run
            (GuiderSpringBootApplication.class, args);

        context.registerShutdownHook();

        for (String beanName : context.getBeanDefinitionNames()) {
            System.out.println(beanName);
        }

        ShutdownHookService shutdownHook =
            context.getBean(ShutdownHookService.class);
        Runtime.getRuntime().addShutdownHook
            (new Thread(new ShutdownHook(shutdownHook)));
    }

}
